package network

import (
	"lenet/network/layers"
)

type Network struct {
	layers []layers.LayerInterface
}

func (n *Network) AddLayer(layer layers.LayerInterface) {
	n.layers = append(n.layers, layer)
}

func (n *Network) Forward(x []float64) []float64 {
	if n.layers == nil {
		return nil
	}

	for _, layer := range n.layers {
		x = layer.Forward(x)
		/* 		log.Println("forw", x)
		   		log.Println(i + 1)
		   		log.Println() */
	}
	return x
}

func (n *Network) BackProp(x []float64) {
	if n.layers == nil {
		return
	}

	for i := len(n.layers) - 1; i >= 0; i-- {
		/* 		log.Println("back", x)
		   		log.Println(i + 1)
		   		log.Println() */
		x = n.layers[i].BackProp(x)

	}
}
